####################################################################
## author:    Robert A. Huber
## contact:   robert.huber@ir.gess.ethz.ch
## file name: pc_uk_analysis.R
## Context:   Populism and Climate Sceptism, individuals from BES
## started:   2016-10-12
## Summary:   runs Analysis
######################################################################


#minPop <- mean(df_bes$populism, na.rm = T) - sd(df_bes$populism, na.rm=T)
#maxPop <- mean(df_bes$populism, na.rm = T) + sd(df_bes$populism, na.rm=T)
minPop <- min(df_bes$populism, na.rm=T)
maxPop <- max(df_bes$populism, na.rm=T)


#set of control variables
cUK <- " + auth + gender + inc + age  + edu_high + riskTaking + polAttention + satDem + efficacy + genTrust + econPersonalRetro +  econGenRetro  + partyId_ukip + partyId_con + partyId_lab + partyId_lib + partyId_gre + partyId_oth"  # object with "fixed control variables"

#Other controls?
# al_scale + trustMPs +

# Climate Change ----------------------------------------------------------

mcc.1 <- multinom(formula(paste0("climateChange ~ populism + lr" , cUK)), data = df_bes, weights = df_bes$wt_full_w7, maxit = 1000)
summary(mcc.1)
screenreg(mcc.1)

mcc.2 <- multinom(formula(paste0("climateChange ~ populism * lr" , cUK)), data = df_bes, weights = df_bes$wt_full_w7, maxit = 1000)
summary(mcc.2)


# Plot for mcc1 -----------------------------------------------------------


fit.effR <- effect("populism", mcc.1, xlevels = list(populism=seq(minPop,maxPop, length.out = 10)),
                   x.var="populism", confidence.level = 0.95)

PredPropR <- data.frame(fit.effR$model.matrix, fit.effR$prob, fit.effR$lower.prob,
                        fit.effR$upper.prob)

#plot(fit.effR, style= "stacked", colors= c("red", "orange", "yellow", "blue"), rug=FALSE, main = "",
#     ylab = "Probability", xlab="Populismus")

cc1 <- c(PredPropR$prob.Climate.changing.due.to.human.activity, PredPropR$prob.Climate.changing.but.not.due.to.human.activity, PredPropR$prob.Climate.not.changing, PredPropR$prob.Don.t.know)
populism <- rep(PredPropR$populism,4)
lwrCI <- c(PredPropR$L.prob.Climate.changing.due.to.human.activity, PredPropR$L.prob.Climate.changing.but.not.due.to.human.activity, PredPropR$L.prob.Climate.not.changing, PredPropR$L.prob.Don.t.know)
uprCI <- c(PredPropR$U.prob.Climate.changing.due.to.human.activity, PredPropR$U.prob.Climate.changing.but.not.due.to.human.activity, PredPropR$U.prob.Climate.not.changing, PredPropR$U.prob.Don.t.know)
response <- rep(c("...is changing due to human activity", "...is changing but not due to human activity", "...is not changing", "Do not know"), each=10)

df_cc1 <- data.frame(cc1,populism, lwrCI, uprCI, response)
df_cc1$response <- factor(df_cc1$response, levels = c("...is changing due to human activity", "...is changing but not due to human activity", "...is not changing", "Do not know"))


pcc1 <- ggplot(df_cc1, aes(x=populism, y = cc1)) +
  geom_ribbon(aes(ymax=uprCI, ymin=lwrCI), alpha=0.5) +
  #geom_errorbar(aes(ymax=uprCI, ymin=lwrCI, colour= factor(populism))) +
  theme_tufte() +
  ylab("Probability of response") +
  xlab("Level of populist attitudes") +
  #scale_x_continuous(breaks = c(seq(1:10)),  labels=c("Left", "2", "3", "4", "5", "6", "7", "8", "9", "Right")) +
  #scale_fill_manual(values=c("red", "green"),  name="Degree of Populism", labels=c("Low Populism", "High Populism")) +
  facet_wrap(~response) +
  ggtitle("On the subject of climate change do you think the world's climate...") +
  theme(strip.background = element_rect(fill = 'white')) +
  theme(text = element_text(size=20))
pcc1 

# Interaction Plot for mcc2 -----------------------------------------------


fit.effR <- effect("populism*lr", mcc.2, xlevels = list(populism=seq(minPop,maxPop, length.out = 2),
                                                        lr = seq(1,10, length.out = 10)),
                   x.var="lr", confidence.level = 0.95)

PredPropR <- data.frame(fit.effR$model.matrix, fit.effR$prob, fit.effR$lower.prob,
                        fit.effR$upper.prob)

#plot(fit.effR, style= "stacked", colors= c("red", "orange", "yellow", "blue"), rug=FALSE, main = "",
#     ylab = "Probability", xlab="Populismus")

cc2 <- c(PredPropR$prob.Climate.changing.due.to.human.activity, PredPropR$prob.Climate.changing.but.not.due.to.human.activity, PredPropR$prob.Climate.not.changing, PredPropR$prob.Don.t.know)
lr <- c(rep(PredPropR$lr, 4))
populism <- rep(c(minPop,maxPop),40)
lwrCI <- c(PredPropR$L.prob.Climate.changing.due.to.human.activity, PredPropR$L.prob.Climate.changing.but.not.due.to.human.activity, PredPropR$L.prob.Climate.not.changing, PredPropR$L.prob.Don.t.know)
uprCI <- c(PredPropR$U.prob.Climate.changing.due.to.human.activity, PredPropR$U.prob.Climate.changing.but.not.due.to.human.activity, PredPropR$U.prob.Climate.not.changing, PredPropR$U.prob.Don.t.know)
response <- rep(c("is changing due to human activity", "is changing but not due to human activity", "is not changing", "Do not know"), each=20)

df_cc2 <- data.frame(cc2,lr, populism, lwrCI, uprCI, response)
df_cc2$response <- factor(df_cc2$response, levels = c("is changing due to human activity", "is changing but not due to human activity", "is not changing", "Do not know"))


pcc2 <- ggplot(df_cc2, aes(x=lr, y = cc2)) +
  geom_ribbon(aes(fill = factor(populism), ymax=uprCI, ymin=lwrCI), alpha=0.5) +
  #geom_errorbar(aes(ymax=uprCI, ymin=lwrCI, colour= factor(populism))) +
  theme_tufte() +
  ylab("Probability of response") +
  xlab("Political ideology") +
  scale_x_continuous(breaks = c(seq(1:10)),  labels=c("Left", "2", "3", "4", "5", "6", "7", "8", "9", "Right")) +
  scale_fill_manual(values=c("grey60", "grey15"),  name="Degree of populism", labels=c("Low populism", "High populism")) +
  facet_wrap(~response) +
  ggtitle("On the subject of climate change do you think the world's climate ...") +
  theme(strip.background = element_rect(fill = 'white')) +
  theme(text = element_text(size=20))
pcc2 


# Single Plots ------------------------------------------------------------

# pcc.2_1 <- ggplot(PredPropR, aes(x=lr,y=prob.Climate.changing.due.to.human.activity)) +
#   geom_line(aes(colour = factor(populism))) +
#   geom_errorbar(aes(ymax=U.prob.Climate.changing.due.to.human.activity, ymin=L.prob.Climate.changing.due.to.human.activity, colour= factor(populism))) +
#   theme_bw() +
#   ylab("P(climate change is due to human activity)") +
#   xlab("Left-Right Orientation") +
#   ggtitle("On the subject of climate change do you think the world's climate ...") +
#   scale_x_continuous(breaks = c(seq(1:10)),  labels=c("Left", "2", "3", "4", "5", "6", "7", "8", "9", "Right")) +
#   scale_color_manual(values=c("red", "green", "blue"),  name="Degree of Populism", labels=c("Low Populism", "Medium Populism", "High Populism"))
# pcc.2_1
# 
# pcc.2_2 <- ggplot(PredPropR, aes(x=lr,y=prob.Climate.changing.but.not.due.to.human.activity)) +
#   geom_line(aes(colour = factor(populism))) +
#   geom_errorbar(aes(ymax=U.prob.Climate.changing.but.not.due.to.human.activity, ymin=L.prob.Climate.changing.but.not.due.to.human.activity, colour= factor(populism))) +
#   theme_bw() +
#   ylab("P(climate is changing but not due to human activity)") +
#   xlab("Left-Right Orientation") +
#   ggtitle("On the subject of climate change do you think the world's climate ...") +
#   scale_x_continuous(breaks = c(seq(1:10)),  labels=c("Left", "2", "3", "4", "5", "6", "7", "8", "9", "Right")) +
#   scale_color_manual(values=c("red", "green", "blue"),  name="Degree of Populism", labels=c("Low Populism", "Medium Populism", "High Populism"))
# pcc.2_2
# # 
# pcc.2_3 <- ggplot(PredPropR, aes(x=lr,y=prob.Climate.not.changing)) +
#   geom_line(aes(colour = factor(populism))) +
#   geom_errorbar(aes(ymax=U.prob.Climate.not.changing, ymin=L.prob.Climate.not.changing, colour= factor(populism))) +
#   theme_bw() +
#   ylab("P(climate not changing)") +
#   ggtitle("On the subject of climate change do you think the world's climate ...") +
#   xlab("Left-Right Orientation") +scale_x_continuous(breaks = c(seq(1:10)),  labels=c("Left", "2", "3", "4", "5", "6", "7", "8", "9", "Right")) +
#   scale_color_manual(values=c("red", "green", "blue"),  name="Degree of Populism", labels=c("Low Populism", "Medium Populism", "High Populism"))
# pcc.2_3
# 
# pcc.2_4 <- ggplot(PredPropR, aes(x=lr,y=prob.Don.t.know)) +
#   geom_line(aes(colour = factor(populism))) +
#   geom_errorbar(aes(ymax=U.prob.Don.t.know, ymin=L.prob.Don.t.know, colour= factor(populism))) +
#   theme_bw() +
#   ylab("P(Don't Know)") +
#   xlab("Left-Right Orientation") +
#   ggtitle("On the subject of climate change do you think the world's climate ...") +
#   scale_x_continuous(breaks = c(seq(1:10)),  labels=c("Left", "2", "3", "4", "5", "6", "7", "8", "9", "Right")) +
#   scale_color_manual(values=c("red", "green", "blue"),  name="Degree of Populism", labels=c("Low Populism", "Medium Populism", "High Populism"))
# pcc.2_4

# Environment vs. Growth --------------------------------------------------

meG.1 <- lm(formula(paste0("enviroGrowth ~ populism + lr", cUK)), data = df_bes, weights = df_bes$wt_full_w7)
summary(meG.1)

meG.2 <- lm(formula(paste0("enviroGrowth ~ populism * lr", cUK)), data = df_bes, weights = df_bes$wt_full_w7)
summary(meG.2)


# Plot meG.1 --------------------------------------------------------------


fit.effR <- effect("populism", meG.1, xlevels = list(populism=seq(minPop,maxPop, length.out = 10)),
                   x.var="populism", confidence.level = 0.95)

PredPropR <- data.frame(fit.effR$model.matrix, fit.effR$fit, fit.effR$lower, 
                        fit.effR$upper)

peG1 <- ggplot(PredPropR, aes(x=populism, y = fit.effR.fit)) +
  geom_ribbon(aes(ymax=fit.effR.upper, ymin=fit.effR.lower), alpha = 0.5) +
  theme_tufte() +
  ylab("Prediction") +
  xlab("Level of populist attitudes") +
  ylim(0,10) + 
#  scale_x_continuous(breaks = c(seq(1:10)),  labels=c("Left", "2", "3", "4", "5", "6", "7", "8", "9", "Right")) +
#  scale_fill_manual(values=c("red", "green"),  name="Degree of Populism", labels=c("Low Populism", "High Populism")) +
  ggtitle("Environmental protection (0) vs. economic growth (10)") +
  theme(text = element_text(size=20))
peG1

# Interaction Plot meG.2 -- Fit -------------------------------------------

fit.effR <- effect("populism*lr", meG.2, xlevels = list(populism=seq(minPop,maxPop, length.out = 2),
                                                        lr = seq(1,10, length.out = 10)),
                   x.var="lr", confidence.level = 0.95)

PredPropR <- data.frame(fit.effR$model.matrix, fit.effR$fit, fit.effR$lower, 
                        fit.effR$upper)

peG2 <- ggplot(PredPropR, aes(x=lr, y = fit.effR.fit)) +
  geom_ribbon(aes(ymax=fit.effR.upper, ymin=fit.effR.lower, fill= factor(populism)), alpha = 0.5) +
  theme_tufte() +
  ylab("Prediction") +
  xlab("Political ideology") +
  scale_x_continuous(breaks = c(seq(1:10)),  labels=c("Left", "2", "3", "4", "5", "6", "7", "8", "9", "Right")) +
  scale_fill_manual(values=c("grey60", "grey15"),  name="Degree of populism", labels=c("Low populism", "High populism")) +
  ggtitle("Environmental protection (0) vs. economic growth (10)") +
  theme(text = element_text(size=20))
peG2

# Interaction Plot meG.2 -- Traditional --------------------------------------------------

cov <- vcov(meG.2)

beta.hat <- coef(meG.2)

z <- seq(1, length.out = 10)

dy.dx.3eG <- beta.hat[2] + beta.hat[length(beta.hat)]*z
se.dy.dx.3eG <- sqrt(cov[2,2] + z^2*cov[length(beta.hat),length(beta.hat)] + 2*z*cov[2,length(beta.hat)])

upr.3eG <- dy.dx.3eG + 1.645 * se.dy.dx.3eG
lwr.3eG <- dy.dx.3eG - 1.645 * se.dy.dx.3eG

df_eG2 <- data.frame(dy.dx.3eG, se.dy.dx.3eG, z, upr.3eG, lwr.3eG)

p_eG2_margins <- ggplot(df_eG2, aes(x=z, y=dy.dx.3eG)) +
  geom_line() + 
  geom_line(aes(y= lwr.3eG, x= z), linetype = "dashed") +
  geom_line(aes(y= upr.3eG, x= z), linetype = "dashed") +
  #geom_ribbon(aes(ymin=lwr,ymax=upr),alpha=0.1) +
  theme_tufte() +
  geom_hline(yintercept = 0) +
  xlab("Political ideology") +
  ylab("Marginal effect") +
  scale_x_continuous(breaks = c(seq(1:10)))+
  theme(text = element_text(size=20))
p_eG2_margins

# Environmental Protection ------------------------------------------------

meP.1 <- multinom(formula(paste0("enviroProtection_RBC ~ populism + lr", cUK)), data = df_bes, weights = df_bes$wt_full_w7, maxit = 1000)
summary(meP.1)

meP.2 <- multinom(formula(paste0("enviroProtection ~ populism * lr", cUK)), data = df_bes, weights = df_bes$wt_full_w7, maxit = 1000)
summary(meP.2)

meP.3 <- multinom(formula(paste0("enviroProtection_RBC ~ populism * lr", cUK)), data = df_bes, weights = df_bes$wt_full_w7, maxit = 1000)
summary(meP.3)


# Plot meP.1 --------------------------------------------------------------


fit.effR <- effect("populism", meP.1, xlevels = list(populism=seq(minPop,maxPop, length.out = 10)),
                   x.var="populism", confidence.level = 0.95)

PredPropR <- data.frame(fit.effR$model.matrix, fit.effR$prob, fit.effR$lower.prob, 
                        fit.effR$upper.prob)

# plot(fit.effR, style= "stacked", colors= c("red", "orange", "yellow", "blue", "green", "grey"), rug=FALSE, main = "", 
#      ylab = "Probability", xlab="Populismus")


eP1 <- c(PredPropR$prob.Gone.too.far, PredPropR$prob.About.right, PredPropR$prob.Not.enough, PredPropR$prob.Don.t.know)
populism <- rep(PredPropR$populism,4)
uprCI <- c(PredPropR$U.prob.Gone.too.far, PredPropR$U.prob.About.right, PredPropR$U.prob.Not.enough, PredPropR$U.prob.Don.t.know)
lwrCI <- c(PredPropR$L.prob.Gone.too.far, PredPropR$L.prob.About.right, PredPropR$L.prob.Not.enough, PredPropR$L.prob.Don.t.know)
response <- rep(c("Gone too far", "About right", "Not gone far enough", "Do not know"), each=10)

df_eP1 <- data.frame(eP1,populism, lwrCI, uprCI, response)
df_eP1$response <- factor(df_eP1$response, levels = c("Gone much too far", "Gone too far", "About right", "Not gone far enough", "Not gone nearly far enough", "Do not know"))


peP1 <- ggplot(df_eP1, aes(x=populism, y = eP1)) +
  #  geom_line(aes(colour = factor(populism))) +
  geom_ribbon(aes(ymax=uprCI, ymin=lwrCI), alpha=0.5) +
  theme_tufte() +
  ylab("Probability of response") +
  xlab("Level of populist attitudes") +
  #scale_x_continuous(breaks = c(seq(1:10)),  labels=c("Left", "2", "3", "4", "5", "6", "7", "8", "9", "Right")) +
  #scale_fill_manual(values=c("red", "green"),  name="Degree of Populism", labels=c("Low Populism", "High Populism")) +
  facet_wrap(~response) +
  ggtitle("Do you think that measures to protect the environment\nhave gone too far or not far enough?") +
  theme(strip.background = element_rect(fill = 'white'))+
  theme(text = element_text(size=20))
peP1

# Interaction Plot meP.2 --------------------------------------------------

fit.effR <- effect("populism*lr", meP.2, xlevels = list(populism=seq(minPop,maxPop, length.out = 2),
                                                        lr = seq(1,10, length.out = 10)),
                   x.var="lr", confidence.level = 0.95)

PredPropR <- data.frame(fit.effR$model.matrix, fit.effR$prob, fit.effR$lower.prob, 
                        fit.effR$upper.prob)

# plot(fit.effR, style= "stacked", colors= c("red", "orange", "yellow", "blue", "green", "grey"), rug=FALSE, main = "", 
#      ylab = "Probability", xlab="Populismus")


eP2 <- c(PredPropR$prob.Gone.much.too.far, PredPropR$prob.Gone.too.far, PredPropR$prob.About.right, PredPropR$prob.Not.gone.far.enough, PredPropR$prob.Not.gone.nearly.far.enough, PredPropR$prob.Don.t.know)
lr <- c(rep(PredPropR$lr, 6))
populism <- rep(c(-2,2),60)
lwrCI <- c(PredPropR$L.prob.Gone.much.too.far, PredPropR$L.prob.Gone.too.far, PredPropR$L.prob.About.right, PredPropR$L.prob.Not.gone.far.enough, PredPropR$L.prob.Not.gone.nearly.far.enough, PredPropR$L.prob.Don.t.know)
uprCI <- c(PredPropR$U.prob.Gone.much.too.far, PredPropR$U.prob.Gone.too.far, PredPropR$U.prob.About.right, PredPropR$U.prob.Not.gone.far.enough, PredPropR$U.prob.Not.gone.nearly.far.enough, PredPropR$U.prob.Don.t.know)
response <- rep(c("Gone much too far", "Gone too far", "About right", "Not gone far enough", "Not gone nearly far enough", "Do not know"), each=20)

df_eP2 <- data.frame(eP2,lr, populism, lwrCI, uprCI, response)
df_eP2$response <- factor(df_eP2$response, levels = c("Gone much too far", "Gone too far", "About right", "Not gone far enough", "Not gone nearly far enough", "Do not know"))


peP2 <- ggplot(df_eP2, aes(x=lr, y = eP2)) +
#  geom_line(aes(colour = factor(populism))) +
  geom_ribbon(aes(ymax=uprCI, ymin=lwrCI, fill= factor(populism)), alpha=0.5) +
  theme_tufte() +
  ylab("Probability of response") +
  xlab("Political ideology") +
  scale_x_continuous(breaks = c(seq(1:10)),  labels=c("Left", "2", "3", "4", "5", "6", "7", "8", "9", "Right")) +
  scale_fill_manual(values=c("grey60", "grey15"),  name="Degree of populism", labels=c("Low populism", "High populism")) +
  facet_wrap(~response) +
  ggtitle("Do you think that measures to protect the environment\nhave gone too far or not far enough?") +
  theme(strip.background = element_rect(fill = 'white')) +
  theme(text = element_text(size=20))
peP2


# peP3 Figures ------------------------------------------------------------

fit.effR <- effect("populism*lr", meP.3, xlevels = list(populism=seq(minPop,maxPop, length.out = 2),
                                                        lr = seq(1,10, length.out = 10)),
                   x.var="lr", confidence.level = 0.95)

PredPropR <- data.frame(fit.effR$model.matrix, fit.effR$prob, fit.effR$lower.prob, 
                        fit.effR$upper.prob)

# plot(fit.effR, style= "stacked", colors= c("red", "orange", "yellow", "blue", "green", "grey"), rug=FALSE, main = "", 
#      ylab = "Probability", xlab="Populismus")


eP3 <- c(PredPropR$prob.Gone.too.far, PredPropR$prob.About.right, PredPropR$prob.Not.enough, PredPropR$prob.Don.t.know)
lr <- c(rep(PredPropR$lr, 4))
populism <- rep(c(-2,2),40)
uprCI <- c(PredPropR$U.prob.Gone.too.far, PredPropR$U.prob.About.right, PredPropR$U.prob.Not.enough, PredPropR$U.prob.Don.t.know)
lwrCI <- c(PredPropR$L.prob.Gone.too.far, PredPropR$L.prob.About.right, PredPropR$L.prob.Not.enough, PredPropR$L.prob.Don.t.know)
response <- rep(c("Gone too far", "About right", "Not gone far enough", "Do not know"), each=20)

df_eP3 <- data.frame(eP3,lr, populism, lwrCI, uprCI, response)
df_eP3$response <- factor(df_eP3$response, levels = c("Gone too far", "About right", "Not gone far enough", "Do not know"))


peP3 <- ggplot(df_eP3, aes(x=lr, y = eP3)) +
#  geom_line(aes(colour = factor(populism))) +
  geom_ribbon(aes(ymax=uprCI, ymin=lwrCI, fill= factor(populism)), alpha = .5) +
  theme_tufte() +
  ylab("Probability of response") +
  xlab("Political ideology") +
  scale_x_continuous(breaks = c(seq(1:10)),  labels=c("Left", "2", "3", "4", "5", "6", "7", "8", "9", "Right")) +
  scale_fill_manual(values=c("grey60", "grey15"),  name="Degree of populism", labels=c("Low populism", "High populism")) +
  facet_wrap(~response) +
  ggtitle("Do you think that measures to protect the environment\nhave gone too far or not far enough?") +
  theme(strip.background = element_rect(fill = 'white')) +
  theme(text = element_text(size=20))
peP3


# Single Plots ------------------------------------------------------------

# peP.2_1 <- ggplot(PredPropR, aes(x=lr,y=prob.Gone.much.too.far)) +
#   geom_line(aes(colour = factor(populism))) +
#   geom_errorbar(aes(ymax=U.prob.Gone.much.too.far, ymin=L.prob.Gone.much.too.far, colour= factor(populism))) +
#   theme_bw() +
#   ylab("P(Measures to protect the environment gone much too far)") +
#   xlab("Left-Right Orientation") +
#   scale_x_continuous(breaks = c(seq(1:10)),  labels=c("Left", "2", "3", "4", "5", "6", "7", "8", "9", "Right")) +
#   scale_color_manual(values=c("red", "green", "blue"),  name="Degree of Populism", labels=c("Low Populism", "Medium Populism", "High Populism"))
# peP.2_1
# 
# peP.2_2 <- ggplot(PredPropR, aes(x=lr,y=prob.Gone.too.far)) + 
#   geom_line(aes(colour = factor(populism))) +
#   geom_errorbar(aes(ymax=U.prob.Gone.too.far, ymin=L.prob.Gone.too.far, colour= factor(populism))) +
#   theme_bw() +
#   ylab("P(Measures to protect the environment gone too far)") +
#   xlab("Left-Right Orientation") +
#   scale_x_continuous(breaks = c(seq(1:10))) +
#   scale_color_manual(values=c("red", "green", "blue"),  name="Degree of Populism", labels=c("Low Populism", "Medium Populism", "High Populism"))
# peP.2_2
# 
# peP.2_3 <- ggplot(PredPropR, aes(x=lr,y=prob.About.right)) + 
#   geom_line(aes(colour = factor(populism))) +
#   geom_errorbar(aes(ymax=U.prob.About.right, ymin=L.prob.About.right, colour= factor(populism))) +
#   theme_bw() +
#   ylab("P(Measures to protect the environment are about right)") +
#   xlab("Left-Right Orientation") +
#   scale_x_continuous(breaks = c(seq(1:10))) +
#   scale_color_manual(values=c("red", "green", "blue"),  name="Degree of Populism", labels=c("Low Populism", "Medium Populism", "High Populism"))
# peP.2_3
# 
# peP.2_4 <- ggplot(PredPropR, aes(x=lr,y=prob.Not.gone.far.enough)) + 
#   geom_line(aes(colour = factor(populism))) +
#   geom_errorbar(aes(ymax=U.prob.Not.gone.far.enough, ymin=L.prob.Not.gone.far.enough, colour= factor(populism))) +
#   theme_bw() +
#   ylab("P(Measures to protect the environment not gone far enough)") +
#   xlab("Left-Right Orientation") +
#   scale_x_continuous(breaks = c(seq(1:10))) +
#   scale_color_manual(values=c("red", "green", "blue"),  name="Degree of Populism", labels=c("Low Populism", "Medium Populism", "High Populism"))
# peP.2_4
# 
# peP.2_5 <- ggplot(PredPropR, aes(x=lr,y=prob.Not.gone.nearly.far.enough)) + 
#   geom_line(aes(colour = factor(populism))) +
#   geom_errorbar(aes(ymax=U.prob.Not.gone.nearly.far.enough, ymin=L.prob.Not.gone.nearly.far.enough, colour= factor(populism))) +
#   theme_bw() +
#   ylab("P(Measures to protect the environment not gone nearly far enough)") +
#   xlab("Left-Right Orientation") +
#   scale_x_continuous(breaks = c(seq(1:10))) +
#   scale_color_manual(values=c("red", "green", "blue"),  name="Degree of Populism", labels=c("Low Populism", "Medium Populism", "High Populism"))
# peP.2_5
# 
# peP.2_6 <- ggplot(PredPropR, aes(x=lr,y=prob.Don.t.know)) + 
#   geom_line(aes(colour = factor(populism))) +
#   geom_errorbar(aes(ymax=U.prob.Don.t.know, ymin=L.prob.Don.t.know, colour= factor(populism))) +
#   theme_bw() +
#   ylab("P(Don't know)") +
#   xlab("Left-Right Orientation") +
#   scale_x_continuous(breaks = c(seq(1:10))) +
#   scale_color_manual(values=c("red", "green", "blue"),  name="Degree of Populism", labels=c("Low Populism", "Medium Populism", "High Populism"))
# peP.2_6
# 
# peP3_1 <- ggplot(subset(df_eP3, df_eP3$response == "Gone too far"), aes(x=lr, y = eP3)) +
#   geom_line(aes(colour = factor(populism))) +
#   geom_errorbar(aes(ymax=uprCI, ymin=lwrCI, colour= factor(populism))) +
#   theme_bw() +
#   ylab("P(Gone too far)") +
#   xlab("Political Ideology") +
#   scale_x_continuous(breaks = c(seq(1:10)),  labels=c("Left", "2", "3", "4", "5", "6", "7", "8", "9", "Right")) +
#   scale_color_manual(values=c("red", "green", "blue"),  name="Degree of Populism", labels=c("Low Populism", "Medium Populism", "High Populism")) +
#   ggtitle("Do you think that measures to protect the environment have gone too far or not far enough?") +
#   theme(strip.background = element_rect(fill = 'white'))
# peP3_1
# 
# peP3_2 <- ggplot(subset(df_eP3, df_eP3$response == "About right"), aes(x=lr, y = eP3)) +
#   geom_line(aes(colour = factor(populism))) +
#   geom_errorbar(aes(ymax=uprCI, ymin=lwrCI, colour= factor(populism))) +
#   theme_bw() +
#   ylab("P(About right)") +
#   xlab("Political Ideology") +
#   scale_x_continuous(breaks = c(seq(1:10)),  labels=c("Left", "2", "3", "4", "5", "6", "7", "8", "9", "Right")) +
#   scale_color_manual(values=c("red", "green", "blue"),  name="Degree of Populism", labels=c("Low Populism", "Medium Populism", "High Populism")) +
#   ggtitle("Do you think that measures to protect the environment have gone too far or not far enough?") +
#   theme(strip.background = element_rect(fill = 'white'))
# peP3_2
# 
# peP3_3 <- ggplot(subset(df_eP3, df_eP3$response == "Not gone far enough"), aes(x=lr, y = eP3)) +
#   geom_line(aes(colour = factor(populism))) +
#   geom_errorbar(aes(ymax=uprCI, ymin=lwrCI, colour= factor(populism))) +
#   theme_bw() +
#   ylab("P(Not gone far enough)") +
#   xlab("Political Ideology") +
#   scale_x_continuous(breaks = c(seq(1:10)),  labels=c("Left", "2", "3", "4", "5", "6", "7", "8", "9", "Right")) +
#   scale_color_manual(values=c("red", "green", "blue"),  name="Degree of Populism", labels=c("Low Populism", "Medium Populism", "High Populism")) +
#   ggtitle("Do you think that measures to protect the environment have gone too far or not far enough?") +
#   theme(strip.background = element_rect(fill = 'white'))
# peP3_3
# 
# peP3_4 <- ggplot(subset(df_eP3, df_eP3$response == "Do not know"), aes(x=lr, y = eP3)) +
#   geom_line(aes(colour = factor(populism))) +
#   geom_errorbar(aes(ymax=uprCI, ymin=lwrCI, colour= factor(populism))) +
#   theme_bw() +
#   ylab("P(Do not know)") +
#   xlab("Political Ideology") +
#   scale_x_continuous(breaks = c(seq(1:10)),  labels=c("Left", "2", "3", "4", "5", "6", "7", "8", "9", "Right")) +
#   scale_color_manual(values=c("red", "green", "blue"),  name="Degree of Populism", labels=c("Low Populism", "Medium Populism", "High Populism")) +
#   ggtitle("Do you think that measures to protect the environment have gone too far or not far enough?") +
#   theme(strip.background = element_rect(fill = 'white'))
# peP3_4

